package com.fl.rabbitmq.rabbitmqconsumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DrectRabbitMqConfiguration {
    //创建交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("direct_order_echange",true,false);
    }
    //创建队列
    @Bean
    public Queue Directsmsqueue(){
        return new Queue("smsqueue.direct.queue",true);
    }

    @Bean
    public Queue DirectEmailqueue(){
        return new Queue("Emailqueue.direct.queue",true);
    }

    @Bean
    public Queue Directduanxinqueue(){
        return new Queue("duanxinqueue.direct.queue",true);
    }
    //队列绑定交换机
    @Bean
    public Binding DirectsmsBinding(){
        return BindingBuilder.bind(Directsmsqueue()).to(directExchange()).with("sms");
    }
    @Bean
    public Binding DirectEmailBinding(){
        return BindingBuilder.bind(DirectEmailqueue()).to(directExchange()).with("email");
    }
    @Bean
    public Binding DirectduanxinBinding(){
        return BindingBuilder.bind(Directduanxinqueue()).to(directExchange()).with("duanxin");
    }
}
